﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using LinFu.IoC.Configuration;
using LinFu.IoC.Interfaces;

namespace CoreEx.Common.Repository.Implementation
{
    [Factory(typeof(BindingList<>))]
    public class BindingListFactory : IFactory
    {
        public object CreateInstance(IFactoryRequest request)
        {
            var listType =
                typeof (TrackableBindingList<>).MakeGenericType(request.ServiceType.GetGenericArguments().First());
            var list = Activator.CreateInstance(listType, request.Arguments);

            return list;
        }
    }
}
